<?php

include('conn.php');

//$ajaxnum = json_decode($_POST["ajaxnum"]);
$ajsxconts = 10;
//$ajaxnum_go = $ajaxnum*$ajsxconts;
//$ajaxnum_end = $ajaxnum_go+$ajsxconts; 
//echo $ajaxnum;

$array = array();
$query = mysql_query('SELECT * FROM images WHERE state=1 and id >= ((SELECT MAX(id) FROM images)-(SELECT MIN(id) FROM images)) * RAND() + (SELECT MIN(id) FROM images)  LIMIT '.$ajsxconts);
//遍历数据表
while($rows = mysql_fetch_array($query)){

//可以直接把读取到的数据赋值给数组或者通过字段名的形式赋值也可以
$array[] = $rows;
//$array[$rows['id']] = $rows;
} 

//print_r($array);

//最后通过json_encode()转化数组

echo json_encode($array);


?>